package servlets;

import java.io.File;
import java.io.IOException;

import javax.naming.NamingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import BDs.FabricaBusinessDelegate;
import BDs.FacadeBusinessDelegate;

import parser.ParserXML;

import entitiesdto.SolicitudFabricacionDTO;

 public class SolicitudFabricacionSVL extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
   static final long serialVersionUID = 1L;
   
	public SolicitudFabricacionSVL() {
		super();
	}   	
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}  	
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession(true);
		String path = request.getParameter("patharchivo");
		
		SolicitudFabricacionDTO solicitud = null;
		
		if (path != null) {
			ParserXML parser = new ParserXML();
			File archivo = new File(path);
			solicitud = parser.getSolicitudFabricacion(archivo);
			
			if (solicitud != null) {
				try {
					FacadeBusinessDelegate.
				} catch (NamingException e) {
					e.printStackTrace();
				}
			}
		}
		
		session.setAttribute("solicitudParseada", solicitud);
		
		RequestDispatcher dispatcher = request.getRequestDispatcher("/recibirSolicitud.jsp");
		dispatcher.forward(request, response);
	}   	  	    
}